<template>
  <view class="work-container">
    <!-- 轮播图 -->
    <uni-swiper-dot class="uni-swiper-dot-box" :info="data" :current="current" field="content">
      <swiper class="swiper-box" :current="swiperDotIndex" @change="changeSwiper">
        <swiper-item v-for="(item, index) in data" :key="index">
          <view class="swiper-item" @click="clickBannerItem(item)">
            <image :src="item.image" mode="aspectFill" :draggable="false" />
          </view>
        </swiper-item>
      </swiper>
    </uni-swiper-dot>

    <!-- 宫格组件 -->
    <uni-section title="学院风采" type="line"></uni-section>
    <view class="grid-body">
		<view class="item-box" v-for="(item,index) in collegeList" :key="index" @click="handleToCollege(item)">
			<uni-icons custom-prefix="iconfont" type="icon-yubaodaoxinxitongji" size="30"></uni-icons>
			<text class="text">{{item.collegeName}}</text>
        </view>
    </view>
  </view>
</template>

<script>
  import { listColleges } from "@/api/system/college";
  
  export default {
    data() {
      return {
        current: 0,
        swiperDotIndex: 0,
		collegeList: null,
		collegeName: null,
		collegeMsg: null,
        data: [{
            image: '/static/images/banner/banner1.png'
          },
          {
            image: '/static/images/banner/banner2.png'
          },
          {
            image: '/static/images/banner/banner3.jpg'
          }
        ]
      }
    },
	onLoad:function(){
		this.getCollege();
	},
    methods: {
      clickBannerItem(item) {
        console.info(item)
      },
      changeSwiper(e) {
        this.current = e.detail.current
      },
      changeGrid(e) {
        this.$modal.showToast('模块建设中~')
      },
	  getCollege(e){
		  listColleges().then(response =>{
			  this.collegeList = response.rows
			  // console.log(this.collegeList)
		  })
	  },
	  handleToCollege(item) {
		  // console.log(item)
		  this.collegeName = item.collegeName
		  this.collegeMsg = item.collegeMsg
		  this.$tab.navigateTo(`/pages/college/index?name=${this.collegeName}&msg=${this.collegeMsg}`)
	  }
    }
  }
</script>

<style lang="scss">
  /* #ifndef APP-NVUE */
  page {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    background-color: #fff;
    min-height: 100%;
    height: auto;
  }

  view {
    font-size: 14px;
    line-height: inherit;
  }

  /* #endif */

  .uni-icons{
	  margin: 5px;
	  padding: 8px;
  }

  .uni-margin-wrap {
    width: 690rpx;
    width: 100%;
    ;
  }

  .swiper {
    height: 300rpx;
  }

  .swiper-box {
    height: 150px;
  }

  .swiper-item {
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    height: 300rpx;
    line-height: 300rpx;
  }

  @media screen and (min-width: 500px) {
    .uni-swiper-dot-box {
      width: 400px;
      /* #ifndef APP-NVUE */
      margin: 0 auto;
      /* #endif */
      margin-top: 8px;
    }

    .image {
      width: 100%;
    }
  }
  
  .item-box{
	  width: 100%;
	  height: 60px;
	  border: 1px solid gray;
  }
  
  .text {
    text-align: center;
    font-size: 35rpx;
  }
</style>


